import {
	iaxios
} from './index.js';

//console.log(import.meta.env);
function hGetDate() {
	return new Date().DtFormat?.("yyyy-MM-dd HH:mm:ss");
}

;
class CApi {
	_api;
	constructor(server) {
		// const store = useStore();
		// store.dispatch('user/LogOut').then(() => {
		// 	location.href = '/index';
		// })
		let baseApi = import.meta.env.VITE_API;
		if (import.meta.env.DEV) {}
		this._api = new iaxios(baseApi);
		return this._api;
	}
}
const _api = new CApi();


/**设备信息
 * 
 */
class cDev extends capi {
	constructor() {
		super(202);
	}

	/**设备（支路）列表
	 * @param {Object} spaceId
	 * @param {Object} devType 101：医用气体, 26：电表, 27：水表, 2：空调机组
	 */
	async getData(spaceId, devType = 2, pageNum = 1, pageSize = 50) {

		let d = await this.getList(`getDevInfoList?spaceId=${spaceId}&devType=${devType}&pageNum=${pageNum}&pageSize=${pageSize}`);
		/**object 		 
			 
		 */
		return d.data;
	}
}

const callApi = () => {
	return {
		dev: new cDev(), 
	}
}
export default callApi;



/**xxxxxx
 * 
 */
class cTemplate extends capi {
	constructor() {
		super(192);
	}

	/**xxxx
	 * @param {Object} spaceId
	 * @param {Object} year
	 */
	async getData(spaceId, year = new Date().getFullYear()) {

		let d = await this.getList(`xxx?spaceId=${spaceId}&year=${year}`);
		/**object 
		 *  
		 * 
		 */
		return d.data;
	}
}

